package com.leen.video.controller;


import com.leen.admin.entity.Dict;
import com.leen.common.vo.ResponseVO;
import com.leen.common.vo.ResultEnum;
import com.leen.common.vo.ResultVO;
import com.leen.video.entity.AlipayConfig;
import com.leen.video.repository.AlipayConfigRepository;
import com.leen.video.service.AlipayConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 支付宝配置类 前端控制器
 * </p>
 *
 * @author yy
 * @since 2021-05-19
 */
@RestController
@RequestMapping("/video")
public class AlipayConfigController {

    @Autowired
    AlipayConfigService alipayConfigService;

    /**
     * 新增数据
     * @param alipayConfig
     * @return
     */
    @PostMapping(value = "/alipayconfig/add")
    public ResultVO dictAdd(@RequestBody AlipayConfig alipayConfig){
        AlipayConfig save = alipayConfigService.save(alipayConfig);
       if(save!=null){
           return ResultVO.success(ResultEnum.DB_SUCCESS);
       }else {
           return ResultVO.success(ResultEnum.DB_FAILED);
       }

    }

    /**
     *
     * @return
     */
    @GetMapping(value = "/alipayconfig/findall")
    public  ResultVO<ResponseVO> findAll(){
        Iterable<AlipayConfig> all = this.alipayConfigService.findAll();
        return ResultVO.success(all);
    }


    @PostMapping("/alipayconfig/update")
    public ResultVO update(AlipayConfig alipayConfig){
        AlipayConfig save = alipayConfigService.save(alipayConfig);
        if(save!=null){
            return ResultVO.success(ResultEnum.DB_SUCCESS);
        }else {
            return ResultVO.success(ResultEnum.DB_FAILED);
        }
    }
}

